<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>进阶篇-vuex的使用</title>
    <script src="../js/lib/vue.min.js"></script>
    <script src="../js/lib/vuex.js"></script>
</head>
<body>
<div id="app">
    公众号：{{name}}
</div>
<script>
    const store=new Vuex.Store({
        state:{
            count:5
        },
        getters:{
            newCount:state=>state.count*3
            //newCount:function(state){
            //  return state*3;}
        },
        //更改store状态的唯一途径，通过mutations
        mutations:{
            increment(state,n){
                state.count+=n;
            }
        }
    });
    store.commit('increment',10);
    let vm = new Vue({
        el:"#app",
        data:{
            name:"web前端教程"
        }
    });
</script>
</body>
</html>